<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        #input1 {
            width: 400px;
            height: 24px;
            margin-left: 100px;
        }

        div {
            width: 404px;
            height: 300px;
            margin-left: 100px;
            background: #eeeeee;
        }

        #content {
            display: none;
        }
    </style>
</head>
<body>
<br>
<br>
<form action="" method="post">
    <input autocomplete="false" id="input1" name="keyword" onkeyup="autocompletion(this)">
    <input type="submit" value="搜索">
    <div id="content"></div>
</form>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.1.min.js"></script>
<script>
    var content = document.getElementById("content")

    function autocompletion(obj) {
        var prefix = obj.value;
        $.getJSON("http://localhost:8080/autocomplete?prefix=" + prefix.trim(), {},
            function (data) {
                $("#content").html("");
                for (let i = 0; i < data.length; i++) {
                    var pTag = document.createElement('p')
                    pTag.innerText = data[i].university;
                    content.appendChild(pTag)
                }
                $("#content").show();
            });
    }

    $("#input1").blur(function () {
        $("#content").hide();
    })
</script>
</body>
</html>